#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by chy on 2018/1/4 9:01

__author__ = 'ChangYi'

import gevent

import gevent.monkey
gevent.monkey.patch_all()

class foo1():
    def __init__(self,x,a,b,c):
        self.v=x

def foo(i, a, b, c):
    print('Running in foo' + str(i) + ' ' + str(a) + str(b) + str(c))
    gevent.sleep(0)
    print('Explicit context switch to foo again')
    return i
tasks = [ gevent.spawn(foo1,i, 1, 2,3) for i in range(0,10)]
for glet in gevent.joinall(tasks):#type:gevent.Greenlet
    print glet.value.v